
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.8 Pod 调度 · Kubernetes - 痴者工良</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="痴者工良">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="9.jobs_cronjobs.html" />
    
    
    <link rel="prev" href="7.lable.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.whuanle.cn" target="_blank" class="custom-link">痴者工良的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    1.基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1.basic/1.docker.html">
            
                <a href="../1.basic/1.docker.html">
            
                    
                    1.1 说透 Docker：基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1.basic/2.virtual.html">
            
                <a href="../1.basic/2.virtual.html">
            
                    
                    1.2 说透 Docker： 虚拟化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1.basic/3.docker_network.html">
            
                <a href="../1.basic/3.docker_network.html">
            
                    
                    1.3 了解 Docker 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../1.basic/4.pod_docker.html">
            
                <a href="../1.basic/4.pod_docker.html">
            
                    
                    1.4 Docker 和 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../1.basic/5.k8s.html">
            
                <a href="../1.basic/5.k8s.html">
            
                    
                    1.5 K8S入门基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../2.deploy/">
            
                <a href="../2.deploy/">
            
                    
                    2.部署和配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../2.deploy/2.deploy.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../2.deploy/1.minikube.html">
            
                <a href="../2.deploy/1.minikube.html">
            
                    
                    2.1 使用 Minikube 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../2.deploy/2.kubeadm.html">
            
                <a href="../2.deploy/2.kubeadm.html">
            
                    
                    2.2 使用 kubeadm 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../2.deploy/3.kubeadm_ckad.html">
            
                <a href="../2.deploy/3.kubeadm_ckad.html">
            
                    
                    2.3 CKAD认证中的部署教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../2.deploy/4.kubeadm_proxy.html">
            
                <a href="../2.deploy/4.kubeadm_proxy.html">
            
                    
                    2.4 国内代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../2.deploy/5.dashboard.html">
            
                <a href="../2.deploy/5.dashboard.html">
            
                    
                    2.5 Dashboard
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    3.Pod部署和调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="./">
            
                <a href="./">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="1.pod.html">
            
                <a href="1.pod.html">
            
                    
                    3.1 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.deployment.html">
            
                <a href="2.deployment.html">
            
                    
                    3.2 Deployment部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.replica.html">
            
                <a href="3.replica.html">
            
                    
                    3.3 副本集(ReplicaSet)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="4.pod_network.html">
            
                <a href="4.pod_network.html">
            
                    
                    3.34 Pod 端口映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="5.update.html">
            
                <a href="5.update.html">
            
                    
                    3.5 Pod 升级、回滚
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="6.scale.html">
            
                <a href="6.scale.html">
            
                    
                    3.6 Pod 缩放
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="7.lable.html">
            
                <a href="7.lable.html">
            
                    
                    3.7.Pod 标签
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.9" data-path="8.schedule.html">
            
                <a href="8.schedule.html">
            
                    
                    3.8 Pod 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="9.jobs_cronjobs.html">
            
                <a href="9.jobs_cronjobs.html">
            
                    
                    3.9 Jobs、CronJobs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    4.Kubernetes 网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4.network/1.network.html">
            
                <a href="../4.network/1.network.html">
            
                    
                    4.1 Kubernetes 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4.network/2.endpoint.html">
            
                <a href="../4.network/2.endpoint.html">
            
                    
                    4.2 Endpoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4.network/3.ingress.html">
            
                <a href="../4.network/3.ingress.html">
            
                    
                    4.3 ingress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4.network/4.discovery.html">
            
                <a href="../4.network/4.discovery.html">
            
                    
                    4.4 服务发现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    5.volumes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../5.volumes/1.volumes.html">
            
                <a href="../5.volumes/1.volumes.html">
            
                    
                    5.1 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../5.volumes/2.secret_configmap.html">
            
                <a href="../5.volumes/2.secret_configmap.html">
            
                    
                    5.2 secret 和 ConfigMap 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../5.volumes/3.nfts.html">
            
                <a href="../5.volumes/3.nfts.html">
            
                    
                    5.3 NFS卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../5.volumes/4.pv_pvc.html">
            
                <a href="../5.volumes/4.pv_pvc.html">
            
                    
                    5.4 持久化卷
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    6.API 和 安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../7.health/">
            
                <a href="../7.health/">
            
                    
                    7.维护和故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../8.health/README.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../k8s.html">
            
                <a href="../k8s.html">
            
                    
                    Kubernetes 命令概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../ckad.html">
            
                <a href="../ckad.html">
            
                    
                    CKAD 认证帮助
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.8 Pod 调度</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#38-pod-&#x8C03;&#x5EA6;"><b></b>3.8 Pod &#x8C03;&#x5EA6;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4EB2;&#x548C;&#x6027;"><b></b>&#x4EB2;&#x548C;&#x6027;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;"><b></b>&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;</a></li></ul><li><span class="title-icon "></span><a href="#&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;"><b></b>&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6C61;&#x70B9;"><b></b>&#x6C61;&#x70B9;</a></li><li><span class="title-icon "></span><a href="#&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;"><b></b>&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;</a></li><li><span class="title-icon "></span><a href="#&#x5BB9;&#x5FCD;&#x5EA6;"><b></b>&#x5BB9;&#x5FCD;&#x5EA6;</a></li></ul></ul></ul></div><h1 id="38-pod-&#x8C03;&#x5EA6;"><a name="38-pod-&#x8C03;&#x5EA6;" class="anchor-navigation-ex-anchor" href="#38-pod-&#x8C03;&#x5EA6;"><i class="fa fa-link" aria-hidden="true"></i></a>3.8 Pod &#x8C03;&#x5EA6;</h1>
<p>&#x5728;&#x4E0A;&#x4E00;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x4E86; Label&#xFF0C;&#x53EF;&#x4EE5;&#x4E3A;&#x5BF9;&#x8C61;&#x8BBE;&#x7F6E;&#x6807;&#x7B7E;&#xFF0C;&#x5E76;&#x4E14;&#x4F7F;&#x7528;&#x9009;&#x62E9;&#x5668;&#x7B5B;&#x9009;&#x5BF9;&#x8C61;&#xFF0C;&#x672C;&#x7AE0;&#x4E2D;&#x6211;&#x4EEC;&#x5C06;&#x5B66;&#x4E60;&#x8282;&#x70B9;&#x8C03;&#x5EA6;&#x7684;&#x76F8;&#x5173;&#x77E5;&#x8BC6;&#xFF0C;&#x5728;&#x6807;&#x7B7E;&#x4E4B;&#x4E0A;&#x63A7;&#x5236; Pod &#x5728;&#x8282;&#x70B9;&#x4E2D;&#x7684;&#x90E8;&#x7F72;&#x3002;</p>
<h2 id="&#x4EB2;&#x548C;&#x6027;"><a name="&#x4EB2;&#x548C;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x4EB2;&#x548C;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EB2;&#x548C;&#x6027;</h2>
<h3 id="&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;"><a name="&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;</h3>
<p>&#x524D;&#x9762;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x4E86; <code>nodeSelector</code> &#xFF0C;Deployment &#x7B49;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>nodeSelector</code> &#x9009;&#x62E9;&#x5408;&#x9002;&#x7684;&#x8282;&#x70B9;&#x90E8;&#x7F72; Pod&#x3002;</p>
<p>&#x4F8B;&#x5982;&#x9009;&#x62E9;&#x78C1;&#x76D8;&#x7A7A;&#x95F4;&#x5927;&#x7684;&#x8282;&#x70B9;&#x90E8;&#x7F72; Pod&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml">    <span class="token key atrule">spec</span><span class="token punctuation">:</span>
      <span class="token key atrule">containers</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> <span class="token key atrule">image</span><span class="token punctuation">:</span> nginx<span class="token punctuation">:</span>latest
        <span class="token key atrule">name</span><span class="token punctuation">:</span> nginx
      <span class="token key atrule">nodeSelector</span><span class="token punctuation">:</span>
        <span class="token key atrule">disksize</span><span class="token punctuation">:</span> <span class="token string">&quot;big&quot;</span>
</code></pre>
<p>&#x800C;&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027;&#x7C7B;&#x4F3C;&#x4E8E; <code>nodeSelector</code> &#xFF0C;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x8282;&#x70B9;&#x4E0A;&#x7684;&#x6807;&#x7B7E;&#x7EA6;&#x675F; Pod &#x53EF;&#x4EE5;&#x8C03;&#x5EA6;&#x5230;&#x54EA;&#x4E9B;&#x8282;&#x70B9;&#x3002;</p>
<p>Pod &#x4EB2;&#x548C;&#x6027;&#x6709;&#x4E24;&#x79CD;&#x522B;&#x4E3A;&#xFF1A;</p>
<ul>
<li><p><code>requiredDuringSchedulingIgnoredDuringExecution</code></p>
<p>&#x786C;&#x9700;&#x6C42;&#xFF0C;&#x5C06; Pod &#x8C03;&#x5EA6;&#x5230;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x5FC5;&#x987B;&#x6EE1;&#x8DB3;&#x7684;&#x89C4;&#x5219;&#x3002;</p>
</li>
<li><p><code>preferredDuringSchedulingIgnoredDuringExecution</code>&#x3002;</p>
<p>&#x5C3D;&#x91CF;&#x6EE1;&#x8DB3;&#xFF0C;&#x5C1D;&#x8BD5;&#x6267;&#x884C;&#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x4FDD;&#x8BC1;&#x504F;&#x597D;&#x3002;</p>
</li>
</ul>
<p>&#x8FD9;&#x662F;&#x4ECE; Kubernetes &#x5B98;&#x65B9;&#x6587;&#x6863;&#x627E;&#x5230;&#x7684;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> Pod
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> with<span class="token punctuation">-</span>node<span class="token punctuation">-</span>affinity
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">affinity</span><span class="token punctuation">:</span>
    <span class="token key atrule">nodeAffinity</span><span class="token punctuation">:</span>
      <span class="token key atrule">requiredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
        <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
        <span class="token punctuation">-</span> <span class="token key atrule">matchExpressions</span><span class="token punctuation">:</span>
          <span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> kubernetes.io/e2e<span class="token punctuation">-</span>az<span class="token punctuation">-</span>name
            <span class="token key atrule">operator</span><span class="token punctuation">:</span> In
            <span class="token key atrule">values</span><span class="token punctuation">:</span>
            <span class="token punctuation">-</span> e2e<span class="token punctuation">-</span>az1
            <span class="token punctuation">-</span> e2e<span class="token punctuation">-</span>az2
      <span class="token key atrule">preferredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> <span class="token key atrule">weight</span><span class="token punctuation">:</span> <span class="token number">1</span>
        <span class="token key atrule">preference</span><span class="token punctuation">:</span>
          <span class="token key atrule">matchExpressions</span><span class="token punctuation">:</span>
          <span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> another<span class="token punctuation">-</span>node<span class="token punctuation">-</span>label<span class="token punctuation">-</span>key
            <span class="token key atrule">operator</span><span class="token punctuation">:</span> In
            <span class="token key atrule">values</span><span class="token punctuation">:</span>
            <span class="token punctuation">-</span> another<span class="token punctuation">-</span>node<span class="token punctuation">-</span>label<span class="token punctuation">-</span>value
  <span class="token key atrule">containers</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> with<span class="token punctuation">-</span>node<span class="token punctuation">-</span>affinity
    <span class="token key atrule">image</span><span class="token punctuation">:</span> k8s.gcr.io/pause<span class="token punctuation">:</span><span class="token number">2.0</span>
</code></pre>
<p>&#x8FD9;&#x4E2A; YAML &#x7684;&#x5C42;&#x7EA7;&#x592A;&#x591A;&#xFF0C;&#x5173;&#x4E8E;&#x4EB2;&#x548C;&#x6027;&#x90E8;&#x5206;&#x7684;&#x5185;&#x5BB9;&#x62BD;&#x9009;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml">  <span class="token key atrule">affinity</span><span class="token punctuation">:</span>
    <span class="token key atrule">nodeAffinity</span><span class="token punctuation">:</span>
      <span class="token key atrule">requiredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
        <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
        <span class="token punctuation">-</span> <span class="token key atrule">matchExpressions</span><span class="token punctuation">:</span>
        <span class="token punctuation">...</span> <span class="token punctuation">...</span>
      <span class="token key atrule">preferredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
        <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
        <span class="token punctuation">-</span> <span class="token key atrule">matchExpressions</span><span class="token punctuation">:</span> 
        <span class="token punctuation">...</span> <span class="token punctuation">...</span>
</code></pre>
<p>affinity &#x914D;&#x7F6E;&#x4EB2;&#x5BC6;&#x5173;&#x7CFB;&#xFF1B;&#x4EB2;&#x548C;&#x6027;&#x6709;&#x591A;&#x79CD;&#x7C7B;&#x578B;&#xFF0C;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x4E86; nodeAffinity &#x8BBE;&#x7F6E;&#x8282;&#x70B9;&#x4EB2;&#x5BC6;&#x5173;&#x7CFB;&#xFF0C;&#x6700;&#x540E;&#x662F;&#x4EB2;&#x548C;&#x6027;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5B83;&#x4EEC;&#x8868;&#x793A;&#x5FC5;&#x987B;&#x6EE1;&#x8DB3;(requiredDuring)&#x548C;&#x5C3D;&#x91CF;&#x6EE1;&#x8DB3;( preferredDuring)&#x3002;</p>
<p>requiredDuring &#x90E8;&#x5206;&#x7684;&#x89C4;&#x5219;&#x5B9A;&#x4E49;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml">      <span class="token key atrule">requiredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
        <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
        <span class="token punctuation">-</span> <span class="token key atrule">matchExpressions</span><span class="token punctuation">:</span>
          <span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> kubernetes.io/e2e<span class="token punctuation">-</span>az<span class="token punctuation">-</span>name
            <span class="token key atrule">operator</span><span class="token punctuation">:</span> In
            <span class="token key atrule">values</span><span class="token punctuation">:</span>
            <span class="token punctuation">-</span> e2e<span class="token punctuation">-</span>az1
            <span class="token punctuation">-</span> e2e<span class="token punctuation">-</span>az2
</code></pre>
<p><code>requiredDuringSchedulingIgnoredDuringExecution</code> &#x4EB2;&#x548C;&#x6027;&#x7684;&#x7EA6;&#x675F;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x6807;&#x7B7E;&#x9009;&#x62E9;&#x5668;&#x6765;&#x8868;&#x793A;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token punctuation">..</span>. <span class="token punctuation">..</span>. -l kubernetes.io/e2e-az-name <span class="token keyword">in</span> <span class="token punctuation">(</span>e2e-az1,e2e-az2<span class="token punctuation">)</span>
</code></pre>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x4E86;&#x591A;&#x4E2A; nodeSelectorTerms &#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">requiredDuringSchedulingIgnoredDuringExecution</span><span class="token punctuation">:</span>
  <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
  <span class="token punctuation">...</span>
  <span class="token key atrule">nodeSelectorTerms</span><span class="token punctuation">:</span>
</code></pre>
<p>&#x5219;<strong>&#x53EA;&#x9700;&#x8981;&#x6EE1;&#x8DB3;&#x5176;&#x4E2D;&#x4E00;&#x79CD;&#x8868;&#x8FBE;&#x5F0F;&#x5373;&#x53EF;&#x8C03;&#x5EA6; Pod &#x5230; &#x8282;&#x70B9;&#x4E0A;</strong>&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x518D;&#x56DE;&#x5FC6;&#x4E00;&#x4E0B;&#xFF0C;&#x8282;&#x70B9;&#x9009;&#x62E9;&#x5668;&#x53EB; <code>nodeSelector</code>&#xFF0C;&#x800C;&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027;&#x53EB;  <code>nodeAffinity</code>&#xFF0C;&#x5B83;&#x4EEC;&#x90FD;&#x53EF;&#x4EE5;&#x8BA9; Deployment &#x7B49;&#x5BF9;&#x8C61;&#x90E8;&#x7F72; Pod &#x65F6;&#x9009;&#x62E9;&#x5408;&#x9002;&#x7684;&#x8282;&#x70B9;&#xFF0C;&#x5B83;&#x4EEC;&#x90FD;&#x662F;&#x4F7F;&#x7528;&#x6807;&#x7B7E;(Label)&#x6765;&#x5B8C;&#x6210;&#x9009;&#x62E9;&#x5DE5;&#x4F5C;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4F60;&#x540C;&#x65F6;&#x6307;&#x5B9A;&#x4E86; <code>nodeSelector</code> &#x548C; <code>nodeAffinity</code> &#xFF0C;&#x5219;&#x4E24;&#x8005;&#x5FC5;&#x987B;&#x540C;&#x65F6;&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#xFF0C; &#x624D;&#x80FD;&#x5C06; Pod &#x8C03;&#x5EA6;&#x5230;&#x5019;&#x9009;&#x8282;&#x70B9;&#x4E0A;&#x3002;</p>
<p>&#x9664;&#x4E86;&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027;&#xFF0C;&#x4E5F;&#x6709; Pod &#x4EB2;&#x548C;&#x6027;&#x3002;</p>
<p>&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027;&#x8BED;&#x6CD5;&#x652F;&#x6301;&#x4E0B;&#x9762;&#x7684;&#x64CD;&#x4F5C;&#x7B26;&#xFF1A; <code>In</code>&#xFF0C;<code>NotIn</code>&#xFF0C;<code>Exists</code>&#xFF0C;<code>DoesNotExist</code>&#xFF0C;<code>Gt</code>&#xFF0C;<code>Lt</code>&#x3002;</p>
<p>Pod &#x4EB2;&#x548C;&#x6027;&#x4E0E;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x7684;&#x5408;&#x6CD5;&#x64CD;&#x4F5C;&#x7B26;&#x6709; <code>In</code>&#xFF0C;<code>NotIn</code>&#xFF0C;<code>Exists</code>&#xFF0C;<code>DoesNotExist</code>&#x3002;</p>
<p>&#x901A;&#x8FC7; <code>Affinity</code> &#x540E;&#x7F00; &#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4EB2;&#x548C;&#x6027;&#xFF0C;&#x4F8B;&#x5982;&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027; <code>nodeAffinity</code>&#x3002;&#x800C;&#x8BBE;&#x7F6E;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x4F7F;&#x7528; <code>AntiAffinity</code> &#x540E;&#x7F00;&#xFF0C;&#x4F8B;&#x5982; <code>nodeAntiAffinity</code>&#x3002;</p>
<p>&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x8DDF;&#x4EB2;&#x548C;&#x6027;&#x4E00;&#x6837;&#xFF0C;&#x90FD;&#x6709; <code>requiredDuringSchedulingIgnoredDuringExecution</code> &#x786C;&#x9650;&#x5236;&#x548C; <code>preferredDuringSchedulingIgnoredDuringExecution</code> &#x8F6F;&#x9650;&#x5236;&#xFF0C;&#x53EA;&#x662F;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x662F;&#x76F8;&#x53CD;&#x7684;&#x8868;&#x793A;&#xFF0C;&#x5982;&#x679C;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x5219;&#x4E0D;&#x80FD;&#x8C03;&#x5EA6;&#x3002;</p>
<p>&#x5173;&#x4E8E;&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x7684;&#x8BF4;&#x660E;&#x5C31;&#x5230;&#x8FD9;&#x91CC;&#xFF0C;&#x8FD9;&#x4E24;&#x8005;&#x7684;&#x914D;&#x7F6E;&#x6BD4;&#x8F83;&#x591A;&#x548C;&#x590D;&#x6742;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x5B98;&#x65B9;&#x6587;&#x6863;&#xFF0C;&#x8FD9;&#x91CC;&#x4E0D;&#x518D;&#x8D58;&#x8FF0;&#x3002;</p>
<blockquote>
<p>&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#x7684; YAML &#x5F88;&#x590D;&#x6742;&#xFF0C;&#x6240;&#x4EE5;&#x624B;&#x5199;&#x4E0D;&#x51FA;&#x6765;&#x7684;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x52AA;&#x529B;&#x4E86;&#x89E3;&#x5927;&#x6982;&#x7684;&#x610F;&#x601D;&#x548C;&#x770B;&#x61C2;&#x5C31;&#x884C;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x65F6;&#x67E5;&#x770B;&#x6587;&#x6863;&#x3002;</p>
<p><a href="https://kubernetes.io/zh/docs/concepts/scheduling-eviction/assign-pod-node" target="_blank">https://kubernetes.io/zh/docs/concepts/scheduling-eviction/assign-pod-node</a></p>
</blockquote>
<h2 id="&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;"><a name="&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;" class="anchor-navigation-ex-anchor" href="#&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;</h2>
<h3 id="&#x6C61;&#x70B9;"><a name="&#x6C61;&#x70B9;" class="anchor-navigation-ex-anchor" href="#&#x6C61;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6C61;&#x70B9;</h3>
<p>&#x524D;&#x9762;&#x63D0;&#x5230;&#x4EB2;&#x548C;&#x6027;&#x548C;&#x53CD;&#x4EB2;&#x548C;&#x6027;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8BA9; Pod &#x9009;&#x62E9;&#x5408;&#x9002;&#x7684; Node(&#x8282;&#x70B9;&#x4EB2;&#x548C;&#x6027;)&#xFF0C;&#x6216;&#x8005; service &#x3001;Deployment &#x9009;&#x62E9;&#x5408;&#x9002;&#x7684; Pod(Pod&#x4EB2;&#x548C;&#x6027;)&#xFF0C;&#x8FD9;&#x4E9B;&#x62E5;&#x6709; Label &#x7684;&#x5BF9;&#x8C61;&#x90FD;&#x662F;<strong>&#x88AB;&#x9009;&#x62E9;&#x7684;</strong>&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x4ECB;&#x7ECD;&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;&#xFF0C;Node &#x548C; Pod &#x5B83;&#x4EEC;&#x53EF;&#x4EE5;&#x6392;&#x65A5; &#x201C;&#x88AB;&#x9009;&#x62E9;&#x201D; &#x7684;&#x547D;&#x8FD0;&#x3002;</p>
<blockquote>
<p><strong>[Info] &#x63D0;&#x793A;</strong></p>
<p>&#x8282;&#x70B9;&#x6C61;&#x70B9;&#xFF1A;&#x5F53;&#x8282;&#x70B9;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#x540E;&#xFF0C;&#x9664;&#x975E; Pod &#x58F0;&#x660E;&#x80FD;&#x591F;&#x5BB9;&#x5FCD;&#x8FD9;&#x4E2A;&#x6C61;&#x70B9;&#xFF0C;&#x5426;&#x5219; Pod &#x4E0D;&#x4F1A;&#x88AB;&#x8C03;&#x5EA6;&#x5230;&#x8FD9;&#x4E2A; &#x8282;&#x70B9;&#x4E0A;&#x3002;</p>
<p>&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x8282;&#x70B9;&#x4E5F;&#x53EF;&#x4EE5; &#x201C;&#x4E11;&#x62D2;&#x201D; Pod&#x3002;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x8282;&#x70B9;&#x5B58;&#x5728;&#x6C61;&#x70B9;&#xFF0C;&#x90A3;&#x4E48; Pod &#x53EF;&#x80FD;&#x4E0D;&#x4F1A;&#x88AB;&#x5206;&#x914D;&#x5230;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#xFF1B;&#x5982;&#x679C;&#x8282;&#x70B9;&#x4E00;&#x5F00;&#x59CB;&#x6CA1;&#x6709;&#x8BBE;&#x7F6E;&#x6C61;&#x70B9;&#xFF0C;&#x7136;&#x540E;&#x90E8;&#x7F72;&#x4E86; Pod&#xFF0C;&#x540E;&#x9762;&#x8282;&#x70B9;&#x8BBE;&#x7F6E;&#x4E86;&#x6C61;&#x70B9;&#xFF0C;<strong>&#x8282;&#x70B9;&#x53EF;&#x80FD;&#x4F1A;&#x5220;&#x9664;&#x5DF2;&#x90E8;&#x7F72;&#x7684; Pod</strong>&#xFF0C;&#x8FD9;&#x79CD;&#x884C;&#x4E3A;&#x79F0;&#x4E3A;<strong>&#x9A71;&#x9010;</strong>&#x3002;</p>
<p>&#x8282;&#x70B9;&#x6C61;&#x70B9;(taint) &#x53EF;&#x4EE5;&#x6392;&#x65A5;&#x4E00;&#x7C7B;&#x7279;&#x5B9A;&#x7684; Pod&#xFF0C;&#x800C; &#x5BB9;&#x5FCD;&#x5EA6;(Tolerations)&#x5219;&#x8868;&#x793A;&#x80FD;&#x591F;&#x5BB9;&#x5FCD;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x6C61;&#x70B9;&#x3002;</p>
<p>&#x8282;&#x70B9;&#x8BF4;&#x81EA;&#x5DF1;&#x53C8;&#x7B28;&#x53C8;&#x4E11;&#xFF0C;&#x4F46;&#x662F; Pod &#x8BF4;&#x6211;&#x4E0D;&#x4ECB;&#x610F;&#xFF0C;&#x8981;&#x8DDF;&#x4F60;&#x8C08;&#x4E00;&#x573A;&#x8F70;&#x8F70;&#x70C8;&#x70C8;&#x7684;&#x604B;&#x7231;&#x3002;</p>
<pre class="language-"><code>Node - taint &gt; &#x6392;&#x65A5; Pod
Pod  - tolerations -&gt; &#x6211;&#x662F;&#x771F;&#x7231;&#xFF0C;&#x6211;&#x80FD;&#x5BB9;&#x5FCD;&#x6C61;&#x70B9; -&gt; Node
</code></pre><p>&#x6C61;&#x70B9;&#x6709;&#x5F3A;&#x5236;&#x548C;&#x5C3D;&#x91CF;&#x4E24;&#x79CD;&#xFF0C;&#x524D;&#x8005;&#x5B8C;&#x5168;&#x6392;&#x65A5;&#xFF0C;&#x540E;&#x8005;&#x5C3D;&#x53EF;&#x80FD;&#x6392;&#x65A5;&#xFF0C;&#x53E6;&#x5916;&#x67D0;&#x4E9B;&#x6C61;&#x70B9;&#x53EF;&#x4EE5;&#x5C06;&#x5DF2;&#x7ECF;&#x5728;&#x8FD9;&#x53F0;&#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72;&#x7684; Pod &#x9010;&#x51FA;&#xFF0C;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x79F0;&#x4E3A; effect&#x3002;</p>
<blockquote>
<p>&#x7CFB;&#x7EDF;&#x4F1A; &#x5C3D;&#x91CF;&#x907F;&#x514D;&#x5C06; Pod &#x8C03;&#x5EA6;&#x5230;&#x5B58;&#x5728;&#x5176;&#x4E0D;&#x80FD;&#x5BB9;&#x5FCD;&#x6C61;&#x70B9;&#x7684;&#x8282;&#x70B9;&#x4E0A;&#xFF0C; &#x4F46;&#x8FD9;&#x4E0D;&#x662F;&#x5F3A;&#x5236;&#x7684;&#x3002;Kubernetes &#x5904;&#x7406;&#x591A;&#x4E2A;&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;&#x7684;&#x8FC7;&#x7A0B;&#x5C31;&#x50CF;&#x4E00;&#x4E2A;&#x8FC7;&#x6EE4;&#x5668;&#xFF1A;&#x4ECE;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x7684;&#x6240;&#x6709;&#x6C61;&#x70B9;&#x5F00;&#x59CB;&#x904D;&#x5386;&#xFF0C; &#x8FC7;&#x6EE4;&#x6389;&#x90A3;&#x4E9B; Pod &#x4E2D;&#x5B58;&#x5728;&#x4E0E;&#x4E4B;&#x76F8;&#x5339;&#x914D;&#x7684;&#x5BB9;&#x5FCD;&#x5EA6;&#x7684;&#x6C61;&#x70B9;&#x3002;</p>
<p>&#x4F46;&#x662F;&#x5982;&#x679C;&#x4F60;&#x53EA;&#x6709;&#x4E00;&#x4E2A; Worker&#xFF0C;&#x90A3;&#x4E48;&#x8BBE;&#x7F6E;&#x4E86;&#x6C61;&#x70B9;&#xFF0C;&#x90A3; Pod &#x4E5F;&#x53EA;&#x80FD;&#x9009;&#x62E9;&#x5728;&#x8FD9;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#x3002;&#x5C31;&#x597D;&#x50CF;&#x5168;&#x4E16;&#x754C;&#x53EA;&#x5269;&#x4E0B;&#x4E00;&#x5973;(Node)&#x4E00;&#x7537;(Pod)&#xFF0C;&#x4E0D;&#x60F3;&#x5728;&#x4E00;&#x8D77;&#x4E5F;&#x5F97;&#x5728;&#x4E00;&#x8D77;&#x3002;</p>
</blockquote>
<p>&#x6DFB;&#x52A0;&#x6C61;&#x70B9;&#x683C;&#x5F0F;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl taint node <span class="token punctuation">[</span>node<span class="token punctuation">]</span> <span class="token assign-left variable">key</span><span class="token operator">=</span>value:<span class="token punctuation">[</span>effect<span class="token punctuation">]</span>
</code></pre>
<p>&#x66F4;&#x65B0;&#x6C61;&#x70B9;&#x6216;&#x8986;&#x76D6;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl taint node <span class="token punctuation">[</span>node<span class="token punctuation">]</span> <span class="token assign-left variable">key</span><span class="token operator">=</span>value:<span class="token punctuation">[</span>effect<span class="token punctuation">]</span> --overwrite<span class="token operator">=</span>true
</code></pre>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x8282;&#x70B9;&#x7684; YAML &#x6587;&#x4EF6;&#xFF0C;&#x4FEE;&#x6539;&#x6C61;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> Node
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
<span class="token punctuation">...</span>
<span class="token punctuation">...</span>
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">taints</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token key atrule">effect</span><span class="token punctuation">:</span> NoSchedule
    <span class="token key atrule">key</span><span class="token punctuation">:</span> node<span class="token punctuation">-</span>role.kubernetes.io/master
<span class="token punctuation">...</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x6765;&#x5B9E;&#x9645;&#x5C1D;&#x8BD5;&#x547D;&#x4EE4;&#xFF0C;&#x4F7F;&#x7528; <code>kubectl taint</code> &#x7ED9;&#x8282;&#x70B9;&#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl taint node instance-2 <span class="token assign-left variable">key1</span><span class="token operator">=</span>value1:NoSchedule
</code></pre>
<p>&#x79FB;&#x9664;&#x6C61;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code>kubectl taint node instance-2 key1=value1:NoSchedule-
</code></pre><blockquote>
<p><strong>[Error] &#x63D0;&#x793A;</strong></p>
<p>&#x6C61;&#x70B9;&#x751F;&#x6210;&#x7684;&#x952E;&#x503C;&#x4E0D;&#x662F;&#x6807;&#x7B7E;&#xFF0C;&#x6C61;&#x70B9;&#x751F;&#x6210;&#x7684;&#x662F; taint &#x5BF9;&#x8C61;&#xFF0C;&#x6807;&#x7B7E;&#x751F;&#x6210;&#x7684;&#x662F; label &#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x7ED9;&#x8282;&#x70B9;&#x8BBE;&#x7F6E;&#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x4E0D;&#x4F1A;&#x5728; Labels &#x4E2D;&#x51FA;&#x73B0;&#xFF0C;&#x800C;&#x662F;&#x5728; <code>Traints</code> &#x4E2D;&#x3002;</p>
</blockquote>
<p>&#x67E5;&#x770B;&#x8282;&#x70B9;&#x7684;&#x6C61;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl get nodes instance-2 -o json <span class="token operator">|</span> jq <span class="token string">&apos;.items[].spec.taints&apos;</span>
</code></pre>
<blockquote>
<p>&#x4F7F;&#x7528; <code>apt install jq</code> &#x5B89;&#x88C5; json &#x7B5B;&#x9009;&#x5DE5;&#x5177;&#x3002;</p>
</blockquote>
<pre class="language-"><code class="lang-json"><span class="token punctuation">[</span>
  <span class="token punctuation">{</span>
    <span class="token property">&quot;effect&quot;</span><span class="token operator">:</span> <span class="token string">&quot;NoSchedule&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;key&quot;</span><span class="token operator">:</span> <span class="token string">&quot;key1&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;value1&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
</code></pre>
<p>&#x6216;&#x8005;&#x4ECE; Node &#x63CF;&#x8FF0;&#x6587;&#x4EF6;&#x4E2D;&#x83B7;&#x53D6;&#x6C61;&#x70B9;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">root@master:~<span class="token comment"># kubectl describe nodes slave1 | grep Taints</span>
Taints:             <span class="token assign-left variable">key1</span><span class="token operator">=</span>value1:NoSchedule
</code></pre>
<p>&#x6C61;&#x70B9;&#x7684;&#x6548;&#x679C;&#x79F0;&#x4E3A; effect &#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x524D;&#x9762;&#x8BBE;&#x7F6E;&#x4E86; <code>{key1,value1}</code>&#xFF0C;&#x5176;&#x9ED8;&#x8BA4;&#x6548;&#x679C;&#x4E3A; NoSchedule&#x3002;</p>
<p>&#x8282;&#x70B9;&#x7684;&#x6C61;&#x70B9;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4E3A;&#x4EE5;&#x4E0B;&#x4E09;&#x79CD;&#x6548;&#x679C;&#xFF1A;</p>
<ul>
<li><code>NoSchedule</code>&#xFF1A;&#x4E0D;&#x80FD;&#x5BB9;&#x5FCD;&#x6B64;&#x6C61;&#x70B9;&#x7684; Pod &#x4E0D;&#x4F1A;&#x88AB;&#x8C03;&#x5EA6;&#x5230;&#x8282;&#x70B9;&#x4E0A;&#xFF1B;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5DF2;&#x5B58;&#x5728;&#x7684; pod&#x3002;</li>
<li><code>PreferNoSchedule</code>&#xFF1A;Kubernetes &#x4F1A;&#x907F;&#x514D;&#x5C06;&#x4E0D;&#x80FD;&#x5BB9;&#x5FCD;&#x6B64;&#x6C61;&#x70B9;&#x7684; Pod &#x5B89;&#x6392;&#x5230;&#x8282;&#x70B9;&#x4E0A;&#x3002;</li>
<li><code>NoExecute</code>&#xFF1A;&#x5982;&#x679C; Pod &#x5DF2;&#x5728;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#xFF0C;&#x5219;&#x4F1A;&#x5C06;&#x8BE5; Pod &#x4ECE;&#x8282;&#x70B9;&#x4E2D;&#x9010;&#x51FA;&#xFF1B;&#x5982;&#x679C;&#x5C1A;&#x672A;&#x5728;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#xFF0C;&#x5219;&#x4E0D;&#x4F1A;&#x5C06;&#x5176;&#x8C03;&#x5EA6;&#x5230;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x3002;</li>
</ul>
<blockquote>
<p>&#x5F53;&#x8282;&#x70B9;&#x8BBE;&#x7F6E;&#x6C61;&#x70B9;&#x540E;&#xFF0C;&#x65E0;&#x8BBA;&#x5176;&#x6548;&#x679C;&#x662F;&#x54EA;&#x4E00;&#x79CD;&#xFF0C;&#x53EA;&#x8981; Pod &#x6CA1;&#x6709;&#x8BBE;&#x7F6E;&#x76F8;&#x5173;&#x7684;&#x5BB9;&#x5FCD;&#x5EA6;&#xFF0C;Pod &#x5C31;&#x4E0D;&#x4F1A;&#x8C03;&#x5EA6;&#x5230;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#x8282;&#x70B9;&#x58F0;&#x660E;&#x4E86; <code>smallcpu</code> &#x6C61;&#x70B9;&#xFF0C;&#x53EA;&#x8981; Pod &#x6CA1;&#x6709;&#x58F0;&#x660E;&#x5BB9;&#x5FCD;&#x6B64; &#x6C61;&#x70B9;&#xFF0C;&#x90A3;&#x4E48; Pod &#x5C31;&#x4E0D;&#x5E94;&#x8BE5;&#x88AB;&#x8C03;&#x7528;&#x5230;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x3002;&#x9664;&#x4E86; <code>smallcpu</code> &#x6C61;&#x70B9;&#x540D;&#x79F0;&#x5916;&#xFF0C;&#x8FD8;&#x6709;&#x503C;&#x4E5F;&#x5C5E;&#x4E8E;&#x89C4;&#x5219;&#x7EA6;&#x675F;&#xFF0C;&#x8FD9;&#x70B9;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x518D;&#x89E3;&#x91CA;&#x3002;</p>
</blockquote>
<h3 id="&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;"><a name="&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;" class="anchor-navigation-ex-anchor" href="#&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;</h3>
<p>&#x5C3D;&#x7BA1;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x7684;&#x6C61;&#x70B9;&#x5B8C;&#x5168;&#x6392;&#x65A5; Pod&#xFF0C;&#x4F46;&#x662F;&#x67D0;&#x4E9B;&#x7CFB;&#x7EDF;&#x521B;&#x5EFA;&#x7684; Pod &#x53EF;&#x4EE5;&#x5BB9;&#x5FCD;&#x6240;&#x6709; <code>NoExecute</code> &#x548C; <code>NoSchedule</code> &#x6C61;&#x70B9;&#xFF0C;&#x56E0;&#x6B64;&#x4E0D;&#x4F1A;&#x88AB;&#x9010;&#x51FA;&#x3002;</p>
<p>&#x4F8B;&#x5982; master &#x8282;&#x70B9;&#x662F;&#x4E0D;&#x4F1A;&#x88AB; Deployment &#x7B49;&#x5206;&#x914D; Pod &#x7684;&#xFF0C;&#x56E0;&#x4E3A; master &#x6709;&#x4E2A;&#x6C61;&#x70B9;&#xFF0C;&#x8868;&#x9762;&#x5B83;&#x53EA;&#x5E94;&#x8BE5;&#x8FD0;&#x884C;<code>kube-system</code> &#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E2D;&#x7684;&#x5F88;&#x591A;&#x7CFB;&#x7EDF; Pod&#xFF0C;&#x7528;&#x6237; Pod &#x4F1A;&#x88AB;&#x6392;&#x65A5;&#x90E8;&#x7F72;&#x5230; master &#x8282;&#x70B9;&#x4E0A;&#x3002;</p>
<pre class="language-"><code class="lang-bash">root@master:~<span class="token comment"># kubectl describe nodes master | grep Taints</span>
Taints:             node-role.kubernetes.io/master:NoSchedule
</code></pre>
<p>&#x5F53;&#x7136;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x4FEE;&#x6539;&#x6C61;&#x70B9;&#xFF0C;&#x53EF;&#x4EE5;&#x8BA9;&#x7528;&#x6237;&#x7684; Pod &#x90E8;&#x7F72;&#x5230; master &#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x672C;&#x5C0F;&#x8282;&#x6211;&#x4EEC;&#x5C06;&#x5B66;&#x4E60;&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x6C61;&#x70B9;&#x4EE5;&#x53CA;&#x76F8;&#x5173;&#x9A71;&#x9010;&#x7684;&#x77E5;&#x8BC6;&#x3002;</p>
<p>&#x67E5;&#x8BE2;&#x6240;&#x6709;&#x8282;&#x70B9;&#x7684;&#x6C61;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl describe nodes <span class="token operator">|</span> <span class="token function">grep</span> Taints
</code></pre>
<pre class="language-"><code># master &#x8F93;&#x51FA;
Taints:             node-role.kubernetes.io/master:NoSchedule
# worker &#x8F93;&#x51FA;
Taints:             key1=value1:NoSchedule
</code></pre><p>master &#x8282;&#x70B9;&#x4E0A;&#x4F1A;&#x6709;&#x4E00;&#x4E2A; <code>node-role.kubernetes.io/master:NoSchedule</code> &#x7684;&#x6C61;&#x70B9;&#xFF0C;Kubernetes &#x90E8;&#x7F72;&#x7528;&#x6237;&#x7684; Pod &#x65F6;&#x4F1A;&#x68C0;&#x67E5;&#x8282;&#x70B9;&#x662F;&#x5426;&#x5B58;&#x5728;&#x6B64;&#x6C61;&#x70B9;&#xFF0C;&#x5982;&#x679C;&#x6709;&#xFF0C;&#x5219;&#x4E0D;&#x4F1A;&#x5728;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72; Pod&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x505A;&#x4E00;&#x4E2A;&#x5B9E;&#x8DF5;&#xFF0C;&#x53BB;&#x6389; master &#x8282;&#x70B9;&#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x4F7F;&#x5F97; &#x7528;&#x6237; Pod &#x80FD;&#x591F;&#x5728;&#x6B64; &#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53BB;&#x9664; master &#x548C; worker &#x7684;&#x6C61;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl taint node instance-1 node-role.kubernetes.io/master:NoSchedule-
kubectl taint node instance-2 <span class="token assign-left variable">key1</span><span class="token operator">=</span>value1:NoSchedule-
<span class="token comment"># instance-1 &#x662F;&#x7B14;&#x8005;&#x7684; master &#x8282;&#x70B9;&#x540D;&#x79F0;</span>
<span class="token comment"># &#x6709;&#x6C61;&#x70B9;&#x5C31;&#x5220;&#x9664;&#xFF0C;&#x6CA1;&#x6709;&#x5C31;&#x4E0D;&#x7528;&#x7BA1;</span>
</code></pre>
<p>&#x7136;&#x540E;&#x90E8;&#x7F72;&#x901A;&#x8FC7; Deployment &#x90E8;&#x7F72; Nginx&#xFF0C;&#x5E76;&#x8BBE;&#x7F6E;&#x526F;&#x672C;&#x96C6;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl create deployment nginxtaint --image<span class="token operator">=</span>nginx:latest --replicas<span class="token operator">=</span><span class="token number">5</span>
</code></pre>
<p>&#x67E5;&#x770B; Pod &#x90FD;&#x90E8;&#x7F72;&#x5230;&#x54EA;&#x4E9B;&#x8282;&#x70B9;&#x4E0A;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl get pods -o wide
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;master &#x8282;&#x70B9;&#x4E5F;&#x88AB;&#x90E8;&#x7F72;&#x4E86; Pod&#x3002;</p>
<p><img src="../.gitbook/assets/&#x65E0;&#x6C61;&#x70B9;&#x8282;&#x70B9;&#x90E8;&#x7F72;.png" alt="&#x65E0;&#x6C61;&#x70B9;&#x8282;&#x70B9;&#x90E8;&#x7F72;"></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;Pod &#x5728;&#x7B14;&#x8005;&#x7684;&#x4E3B;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#x4E86;(instance-1)&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x53EA;&#x662F;&#x7EC3;&#x624B;&#x5B9E;&#x8DF5;&#xFF0C;&#x4E3A;&#x4E86;&#x4FDD;&#x8BC1;&#x96C6;&#x7FA4;&#x5B89;&#x5168;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6062;&#x590D; master &#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x9A71;&#x9010;&#x7528;&#x6237; Pod&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl taint node instance-1 node-role.kubernetes.io/master:NoSchedule
</code></pre>
<p>&#x9664;&#x4E86;&#x4E0A;&#x9762;&#x63D0;&#x53CA;&#x7684; <code>node-role.kubernetes.io/master</code> &#xFF0C;Kubeenetes &#x8FD8;&#x4F1A;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x67D0;&#x79CD;&#x6761;&#x4EF6;&#x4E3A;&#x771F;&#x65F6;&#xFF0C;&#x8282;&#x70B9;&#x63A7;&#x5236;&#x5668;&#x4F1A;&#x81EA;&#x52A8;&#x7ED9;&#x8282;&#x70B9;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#x3002;&#x5F53;&#x524D;&#x5185;&#x7F6E;&#x7684;&#x6C61;&#x70B9;&#x5305;&#x62EC;&#xFF1A;</p>
<ul>
<li><code>node.kubernetes.io/not-ready</code>&#xFF1A;&#x8282;&#x70B9;&#x672A;&#x51C6;&#x5907;&#x597D;&#x3002;&#x8FD9;&#x76F8;&#x5F53;&#x4E8E;&#x8282;&#x70B9;&#x72B6;&#x6001; <code>Ready</code> &#x7684;&#x503C;&#x4E3A; &quot;<code>False</code>&quot;&#x3002;</li>
<li><code>node.kubernetes.io/unreachable</code>&#xFF1A;&#x8282;&#x70B9;&#x63A7;&#x5236;&#x5668;&#x8BBF;&#x95EE;&#x4E0D;&#x5230;&#x8282;&#x70B9;. &#x8FD9;&#x76F8;&#x5F53;&#x4E8E;&#x8282;&#x70B9;&#x72B6;&#x6001; <code>Ready</code> &#x7684;&#x503C;&#x4E3A; &quot;<code>Unknown</code>&quot;&#x3002;</li>
<li><code>node.kubernetes.io/out-of-disk</code>&#xFF1A;&#x8282;&#x70B9;&#x78C1;&#x76D8;&#x8017;&#x5C3D;&#x3002;</li>
<li><code>node.kubernetes.io/memory-pressure</code>&#xFF1A;&#x8282;&#x70B9;&#x5B58;&#x5728;&#x5185;&#x5B58;&#x538B;&#x529B;&#x3002;</li>
<li><code>node.kubernetes.io/disk-pressure</code>&#xFF1A;&#x8282;&#x70B9;&#x5B58;&#x5728;&#x78C1;&#x76D8;&#x538B;&#x529B;&#x3002;</li>
<li><code>node.kubernetes.io/network-unavailable</code>&#xFF1A;&#x8282;&#x70B9;&#x7F51;&#x7EDC;&#x4E0D;&#x53EF;&#x7528;&#x3002;</li>
<li><code>node.kubernetes.io/unschedulable</code>: &#x8282;&#x70B9;&#x4E0D;&#x53EF;&#x8C03;&#x5EA6;&#x3002;</li>
<li><code>node.cloudprovider.kubernetes.io/uninitialized</code>&#xFF1A;&#x5982;&#x679C; kubelet &#x542F;&#x52A8;&#x65F6;&#x6307;&#x5B9A;&#x4E86;&#x4E00;&#x4E2A; &quot;&#x5916;&#x90E8;&quot; &#x4E91;&#x5E73;&#x53F0;&#x9A71;&#x52A8;&#xFF0C; &#x5B83;&#x5C06;&#x7ED9;&#x5F53;&#x524D;&#x8282;&#x70B9;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#x5C06;&#x5176;&#x6807;&#x5FD7;&#x4E3A;&#x4E0D;&#x53EF;&#x7528;&#x3002;&#x5728; cloud-controller-manager &#x7684;&#x4E00;&#x4E2A;&#x63A7;&#x5236;&#x5668;&#x521D;&#x59CB;&#x5316;&#x8FD9;&#x4E2A;&#x8282;&#x70B9;&#x540E;&#xFF0C;kubelet &#x5C06;&#x5220;&#x9664;&#x8FD9;&#x4E2A;&#x6C61;&#x70B9;&#x3002;</li>
</ul>
<p>&#x5F53;&#x8282;&#x70B9;&#x4E0A;&#x7684;&#x8D44;&#x6E90;&#x4E0D;&#x8DB3;&#x65F6;&#xFF0C;&#x4F1A;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#xFF0C;&#x6392;&#x65A5;&#x540E;&#x7EED; Pod &#x5728;&#x6B64; &#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72;&#xFF0C;&#x4F46;&#x4E0D;&#x4F1A;&#x9A71;&#x9010;&#x5DF2;&#x5B58;&#x5728;&#x7684; Pod&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7684; Pod &#x5BF9;&#x673A;&#x5668;&#x8D44;&#x6E90;&#x6709;&#x8981;&#x6C42;&#xFF0C;&#x53EF;&#x4EE5;&#x6392;&#x65A5;&#x76F8;&#x5173;&#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x8981;&#x6C42;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x5BB9;&#x5FCD;&#x76F8;&#x5173;&#x6C61;&#x70B9;&#x3002;</p>
<h3 id="&#x5BB9;&#x5FCD;&#x5EA6;"><a name="&#x5BB9;&#x5FCD;&#x5EA6;" class="anchor-navigation-ex-anchor" href="#&#x5BB9;&#x5FCD;&#x5EA6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5BB9;&#x5FCD;&#x5EA6;</h3>
<p>&#x6C61;&#x70B9;&#x548C;&#x5BB9;&#x5FCD;&#x5EA6;&#x76F8;&#x4E92;&#x914D;&#x5408;&#xFF0C;&#x7528;&#x6765;&#x907F;&#x514D; Pod &#x88AB;&#x5206;&#x914D;&#x5230;&#x4E0D;&#x5408;&#x9002;&#x7684;&#x8282;&#x70B9;&#x4E0A;&#xFF1B;&#x4E5F;&#x53EF;&#x4EE5;&#x8BA9;&#x771F;&#x6B63;&#x5408;&#x9002;&#x7684; Pod &#x90E8;&#x7F72;&#x5230;&#x6709;&#x6C61;&#x70B9;&#x7684;&#x8282;&#x70B9;&#x4E0A;&#x3002;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x6C61;&#x70B9;&#xFF0C;&#x6392;&#x65A5; Pod&#xFF0C;&#x4F46;&#x662F; Pod &#x4E5F;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E; &#x5BB9;&#x5FCD;&#x5EA6;&#xFF0C;&#x5BB9;&#x5FCD;&#x8282;&#x70B9;&#x7684;&#x6C61;&#x70B9;&#x3002;</p>
<p>YAML &#x793A;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">tolerations</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> <span class="token string">&quot;key1&quot;</span>
  <span class="token key atrule">operator</span><span class="token punctuation">:</span> <span class="token string">&quot;Exists&quot;</span>
  <span class="token key atrule">effect</span><span class="token punctuation">:</span> <span class="token string">&quot;NoSchedule&quot;</span>
</code></pre>
<blockquote>
<p>&#x6B64; Pod &#x80FD;&#x591F;&#x5BB9;&#x5FCD;&#x5E26;&#x6709; <code>key1</code> &#x6807;&#x7B7E;&#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x4E14;&#x65E0;&#x8BBA;&#x662F;&#x4EC0;&#x4E48;&#x503C;&#x3002;</p>
</blockquote>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x5E26; value &#x7684;&#x5BB9;&#x5FCD;&#x3002;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">tolerations</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> <span class="token string">&quot;key1&quot;</span>
  <span class="token key atrule">operator</span><span class="token punctuation">:</span> <span class="token string">&quot;Equal&quot;</span>
  <span class="token key atrule">value</span><span class="token punctuation">:</span> <span class="token string">&quot;value1&quot;</span>
  <span class="token key atrule">effect</span><span class="token punctuation">:</span> <span class="token string">&quot;NoSchedule&quot;</span>
</code></pre>
<blockquote>
<p><code>operator</code> &#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x662F; <code>Equal</code>&#x3002;</p>
<p>&#x53EA;&#x6709;&#x5F53;&#x6C61;&#x70B9; <code>key1</code> &#x7684;&#x503C;&#x4E3A; <code>value1</code> &#x65F6;&#xFF0C;&#x624D;&#x5BB9;&#x5FCD;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x5B9A;&#x4E49;&#x591A;&#x4E2A;&#x5BB9;&#x5FCD;&#x5EA6;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">tolerations</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> <span class="token string">&quot;key1&quot;</span>
  <span class="token key atrule">operator</span><span class="token punctuation">:</span> <span class="token string">&quot;Equal&quot;</span>
  <span class="token key atrule">value</span><span class="token punctuation">:</span> <span class="token string">&quot;value1&quot;</span>
  <span class="token key atrule">effect</span><span class="token punctuation">:</span> <span class="token string">&quot;NoSchedule&quot;</span>
<span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> <span class="token string">&quot;key1&quot;</span>
  <span class="token key atrule">operator</span><span class="token punctuation">:</span> <span class="token string">&quot;Equal&quot;</span>
  <span class="token key atrule">value</span><span class="token punctuation">:</span> <span class="token string">&quot;value1&quot;</span>
  <span class="token key atrule">effect</span><span class="token punctuation">:</span> <span class="token string">&quot;NoExecute&quot;</span>
</code></pre>
</blockquote>
<p>&#x4E00;&#x4E2A;&#x5BB9;&#x5FCD;&#x5EA6;&#x548C;&#x4E00;&#x4E2A;&#x6C61;&#x70B9;&#x76F8; &#x201C;&#x5339;&#x914D;&#x201D; &#x662F;&#x6307;&#x5B83;&#x4EEC;&#x6709;&#x4E00;&#x6837;&#x7684;&#x952E;&#x540D;(key)&#x548C;&#x6548;&#x679C;(effect )&#xFF0C;&#x5E76;&#x4E14;&#xFF1A;</p>
<ul>
<li><p>&#x5982;&#x679C; <code>operator</code> &#x662F; <code>Exists</code></p>
<p>&#x6B64;&#x65F6;&#x4E0D;&#x9700;&#x8981;&#x586B;&#x5199; <code>value</code> &#x5B57;&#x6BB5;&#xFF1B;&#x5982;&#x679C;&#x5B58;&#x5728; key &#x4E3A; key1 &#x7684; label&#xFF0C;&#x4E14;&#x6C61;&#x70B9;&#x6548;&#x679C;&#x4E3A; <code>NoSchedule</code>&#xFF0C;&#x65E0;&#x8BBA;&#x662F;&#x4EC0;&#x4E48;&#x503C;&#x90FD;&#x5BB9;&#x5FCD;&#x3002;</p>
</li>
<li><p>&#x5982;&#x679C; <code>operator</code> &#x662F; <code>Equal</code></p>
<p>&#x5219;&#x5B83;&#x4EEC;&#x7684; <code>value</code> &#x5E94;&#x8BE5;&#x76F8;&#x7B49;&#xFF0C;&#x5982;&#x679C;&#x76F8;&#x540C;&#x7684;&#x8BDD;&#xFF0C;&#x5219;&#x5BB9;&#x5FCD;&#xFF0C;&#x5982;&#x679C;&#x53EA;&#x4E0D;&#x540C;&#x5219;&#x5BB9;&#x5FCD;&#x3002;</p>
</li>
<li><p>&#x5982;&#x679C; <code>effect</code> &#x7559;&#x7A7A;</p>
<p>&#x5219;&#x8868;&#x793A;&#x53EA;&#x8981;&#x662F; label &#x4E3A; <code>key1</code> &#x7684;&#x8282;&#x70B9;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x5BB9;&#x5FCD;&#x3002;</p>
</li>
</ul>
<p>&#x5982;&#x679C; Pod &#x7684;&#x5BB9;&#x5FCD;&#x5EA6;&#x8BBE;&#x7F6E;&#x4E3A;&#x4EE5;&#x4E0B; YAML&#xFF1A;</p>
<pre class="language-"><code>tolerations:
  operator: &quot;Exists&quot;
</code></pre><p>&#x5219;&#x8868;&#x793A;&#x6B64; Pod &#x80FD;&#x591F;&#x5BB9;&#x5FCD;&#x4EFB;&#x610F;&#x7684;&#x6C61;&#x70B9;&#xFF0C;&#x65E0;&#x8BBA;&#x8282;&#x70B9;&#x600E;&#x4E48;&#x8BBE;&#x7F6E; <code>key</code>&#x3001;<code>value</code> &#x3001;<code>effect</code> &#xFF0C;&#x6B64; Pod &#x90FD;&#x4E0D;&#x4F1A;&#x4ECB;&#x610F;&#x3002;</p>
<p>&#x5982;&#x679C;&#x8981;&#x5728; master &#x4E0A;&#x4E5F;&#x80FD;&#x90E8;&#x7F72; Pod&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x4FEE;&#x6539; Pod &#x7684;&#x5BB9;&#x5FCD;&#x5EA6;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml">    <span class="token key atrule">spec</span><span class="token punctuation">:</span>
      <span class="token key atrule">tolerations</span><span class="token punctuation">:</span>
      <span class="token comment"># this toleration is to have the daemonset runnable on master nodes</span>
      <span class="token comment"># remove it if your masters can&apos;t run pods</span>
      <span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> node<span class="token punctuation">-</span>role.kubernetes.io/master
        <span class="token key atrule">effect</span><span class="token punctuation">:</span> NoSchedule
</code></pre>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4EFD;&#x5B98;&#x65B9;&#x7684; Pod &#x7684;&#x5E26;&#x6709;&#x5BB9;&#x5FCD;&#x5EA6;&#x7684; YAML &#x6587;&#x4EF6;&#x6A21;&#x677F;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> Pod
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> nginx
  <span class="token key atrule">labels</span><span class="token punctuation">:</span>
    <span class="token key atrule">env</span><span class="token punctuation">:</span> test
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">containers</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> nginx
    <span class="token key atrule">image</span><span class="token punctuation">:</span> nginx
    <span class="token key atrule">imagePullPolicy</span><span class="token punctuation">:</span> IfNotPresent
  <span class="token key atrule">tolerations</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token key atrule">key</span><span class="token punctuation">:</span> <span class="token string">&quot;example-key&quot;</span>
    <span class="token key atrule">operator</span><span class="token punctuation">:</span> <span class="token string">&quot;Exists&quot;</span>
    <span class="token key atrule">effect</span><span class="token punctuation">:</span> <span class="token string">&quot;NoSchedule&quot;</span>
</code></pre>
<blockquote>
<p>&#x6A21;&#x677F;&#x6587;&#x4EF6;&#x5730;&#x5740;&#xFF1A;</p>
<p><a href="https://raw.githubusercontent.com/kubernetes/website/master/content/zh/examples/pods/pod-with-toleration.yaml" target="_blank">https://raw.githubusercontent.com/kubernetes/website/master/content/zh/examples/pods/pod-with-toleration.yaml</a></p>
</blockquote>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x75F4;&#x8005;&#x5DE5;&#x826F; 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x6700;&#x540E;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2021-11-06 20:20:32
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="7.lable.html" class="navigation navigation-prev " aria-label="Previous page: 3.7.Pod 标签">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="9.jobs_cronjobs.html" class="navigation navigation-next " aria-label="Next page: 3.9 Jobs、CronJobs">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.8 Pod 调度","level":"1.4.9","depth":2,"next":{"title":"3.9 Jobs、CronJobs","level":"1.4.10","depth":2,"path":"3.pod/9.jobs_cronjobs.md","ref":"3.pod/9.jobs_cronjobs.md","articles":[]},"previous":{"title":"3.7.Pod 标签","level":"1.4.8","depth":2,"path":"3.pod/7.lable.md","ref":"3.pod/7.lable.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","anchor-navigation-ex","mermaid-gb3","insert-logo","chapter-fold","advanced-emoji","github","splitter","alerts","popup","prism","-highlight","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 痴者工良 2021","modify_label":"文档最后更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"lang":{"flow":"typescript","shell":"bash"},"ignore":["mermaid","eval-js"],"css":["prismjs/themes/prism.css"],"js":["prismjs/prism.js","prismjs/components.js","prismjs/components/prism-go.min.js","prismjs/components/prism-yaml.min.js","prismjs/components/prism-bash.min.js","prismjs/components/prism-shell-session.min.js"]},"github":{"url":"https://github.com/whuanle/kubernetes"},"livereload":{},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"alerts":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"/images/logo.jpg"}},"theme":"default","author":"痴者工良","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Kubernetes - 痴者工良","language":"zh-hans","links":{"sidebar":{"痴者工良的博客":"https://www.whuanle.cn"}},"gitbook":"*","description":"这是一本关于 Kubernetes 的书，作者 痴者工良"},"file":{"path":"3.pod/8.schedule.md","mtime":"2021-11-06T12:20:32.052Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T23:21:22.294Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

